{template '_header'}
<style type='text/css'>
    .table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th{
        padding: 10px 20px;
    }
     .table > tbody>.trbody > td{
         border-top:none !important;
     }
    .trhead td {  background:#efefef;text-align: center}
    .trbody td {  text-align: center; vertical-align:top;border-left:1px solid #f2f2f2;overflow: hidden; font-size:12px;}
    .trorder { background:#f8f8f8;border:1px solid #f2f2f2;text-align:left;}
    .ops { border-right:1px solid #f2f2f2; text-align: center;}
    .paytype span{
        vertical-align: middle;
    }
</style>

<div class="page-header">
    当前位置：<span class="text-primary">分销订单
<span>订单数:  <span class='text-danger'>{$total}</span> 订单金额:  <span class='text-danger'>{$totalmoney}</span> {if !empty($magent['nickname'])}订单推广人:  <span class='text-danger'>{$magent['nickname']}</span>{/if}</span>
</span>
</div>

<div class="page-content">
    <form action="./index.php" method="get" class="form-horizontal table-search" role="form">
        <input type="hidden" name="c" value="site" />
        <input type="hidden" name="a" value="entry" />
        <input type="hidden" name="m" value="ewei_shopv2" />
        <input type="hidden" name="do" value="web" />
        <input type="hidden" name="r" value="commission.statistics.order" />
        <input type="hidden" name="status" value="{$status}" />
        <input type="hidden" name="agentid" value="{$_GPC['agentid']}" />
        <input type="hidden" name="refund" value="{$_GPC['refund']}" />
        <div class="page-toolbar m-b-sm m-t-sm">
                <div class="input-group">
                    <div class="input-group-btn">
                        {php echo tpl_form_field_eweishop_daterange('time', array('starttime'=>date('Y-m-d H:i', $starttime),'endtime'=>date('Y-m-d H:i', $endtime)),true);}
                    </div>
                    <div class="input-group-select">
                        <select name="paytype" class="form-control" style="">
                            <option value="" {if $_GPC['paytype']==''}selected{/if}>支付方式</option>
                            {loop $paytype $key $type}
                            <option value="{$key}" {if $_GPC['paytype'] == "$key"} selected="selected" {/if}>{$type['name']}</option>
                            {/loop}
                        </select>
                    </div>
                    <div class="input-group-select">
                        <select name='searchtime'  class='form-control'   style=""  >
                            <option value=''>不按时间</option>
                            <option value='create' {if $_GPC['searchtime']=='create'}selected{/if}>下单时间</option>
                            <option value='pay' {if $_GPC['searchtime']=='pay'}selected{/if}>付款时间</option>
                            <option value='send' {if $_GPC['searchtime']=='send'}selected{/if}>发货时间</option>
                            <option value='finish' {if $_GPC['searchtime']=='finish'}selected{/if}>完成时间</option>
                        </select>
                    </div>
                    <div class="input-group-select">
                        <select name='searchfield'  class='form-control'   style=""  >
                            <option value='ordersn' {if $_GPC['searchfield']=='ordersn'}selected{/if}>订单号</option>
                            <option value='member' {if $_GPC['searchfield']=='member'}selected{/if}>会员信息</option>
                            <option value='address' {if $_GPC['searchfield']=='address'}selected{/if}>收件人信息</option>
                            <option value='location' {if $_GPC['searchfield']=='location'}selected{/if}>地址信息</option>
                            <option value='expresssn' {if $_GPC['searchfield']=='expresssn'}selected{/if}>快递单号</option>
                            <option value='goodstitle' {if $_GPC['searchfield']=='goodstitle'}selected{/if}>商品名称</option>
                            <option value='goodssn' {if $_GPC['searchfield']=='goodssn'}selected{/if}>商品编码</option>
                            <option value='saler' {if $_GPC['searchfield']=='saler'}selected{/if}>核销员</option>
                            <option value='store' {if $_GPC['searchfield']=='store'}selected{/if}>核销门店</option>
                            {if $merch_plugin}
                            <option value='merch' {if $_GPC['searchfield']=='merch'}selected{/if}>商户名称</option>
                            {/if}
                        </select>
                    </div>
                    <input type="text" class="form-control"  name="keyword" value="{$_GPC['keyword']}" placeholder="请输入关键词"/>
                    <span class="input-group-btn">
                        <button class="btn btn-primary" type="submit"> 搜索</button>
                        <button type="submit" name="export" value="1" class="btn btn-success">导出</button>
                    </span>
                </div>
        </div>

    </form>


    {if count($list)>0}
    <table class='table table-responsive' style='table-layout: fixed;'>
        <tr style='background:#f8f8f8'>
            <td style='width:100px;border-left:1px solid #f2f2f2;'>商品</td>
            <td ></td>
            <td style='width:100px;text-align: right;;'>单价/数量</td>
            <td  style='text-align: center;'>买家</td>
            <td style='text-align: center;'>支付/配送</td>
            <td style='text-align: center;'>价格</td>
            <td style='text-align: center;'>操作</td>
            <td style='text-align: center'>分销商</td>
            <td style='text-align: center'>状态</td>

        </tr>
        {loop $list $item}
        <tr ><td colspan='9' style='height:20px;padding:0;border-top:none;'>&nbsp;</td></tr>
        <tr class='trorder'>
            <td colspan='4' >
                <span style="font-weight: bold;">{php echo date('Y-m-d',$item['createtime'])} {php echo date('H:i:s',$item['createtime'])}</span>
                订单编号:  {$item['ordersn']}
                {if !empty($item['refundstate'])}<label class='label label-danger'>{$r_type[$item['rtype']]}申请</label>{/if}
                {if !empty($item['refundstate']) && $item['rstatus'] == 4}<label class='label label-default'>客户退回物品</label>{/if}
            </td>
            <td colspan='5' style='text-align:right;font-size:12px;' class=''>

                {if $item['merchid'] == 0}
                    {if empty($item['statusvalue'])}
                        {if $item['ismerch'] == 0}
                            {ifp 'order.op.close'}
                            <!--a class='op'  data-toggle='ajaxModal' href="{php echo webUrl('order/op/close',array('id'=>$item['id']))}" >关闭订单</a-->
                            {/if}
                        {/if}
                        {ifp 'order.op.changeprice'}
                        <!--a class='op'  data-toggle='ajaxModal' href="{php echo webUrl('order/op/changeprice',array('id'=>$item['id']))}">订单改价</a-->
                        {/if}
                    {/if}
                {/if}

                {if !empty($item['refundid'])}
                <!--a class='op'  href="{php echo webUrl('order/op/refund', array('id' => $item['id']))}" >维权{if $item['refundstate']>0}处理{else}详情{/if}</a-->
                {/if}

                {if $item['merchid'] == 0}
                    {if $item['statusvalue'] == 2 && !empty($item['addressid'])}
                        {ifp 'order.op.send'}
                        <!--a class="op" data-toggle="ajaxModal"  href="{php echo webUrl('order/op/changeexpress', array('id' => $item['id']))}">修改物流</a-->
                        {/if}
                    {/if}
                {/if}


                {if $item['merchid'] == 0}
                {ifp 'order.op.remarksaler'}
                <a class='op'  data-toggle="ajaxModal" href="{php echo webUrl('order/op/remarksaler', array('id' => $item['id']))}"  >
                    {if !empty($item['remarksaler'])}
                        <i class="icow icow-yibiaoji"></i>
                        备注
                    {else}
                    <i class="icow icow icow-flag-o text-danger"></i>
                    备注
                    {/if}
                </a>
                {/if}
                {/if}

                <!--<a class='op'   href="{php echo webUrl('order', array('op' => 'detail', 'id' => $item['id']))}" >标记</a>-->
            </td>
        </tr>
        {loop $item['goods'] $k $g}
        <tr class='trbody'>
            <td style='overflow:hidden;'><img src="{php echo tomedia($g['thumb'])}" style='width:70px;height:70px;border:1px solid #ccc; padding:1px;' onerror="this.src='../addons/ewei_shopv2/static/images/nopic.png'"></td>
            <td style='text-align: left;overflow:hidden;border-left:none;'  >{$g['title']}{if !empty($g['optiontitle'])}<br/>{$g['optiontitle']}{/if}<br/>{$g['goodssn']}</td>
            <td style='text-align:right;border-left:none;'>{php echo number_format($g['realprice']/$g['total'],2)}<br/>x{$g['total']}</td>

            {if $k==0}
            <td rowspan="{php echo count($item['goods'])}"  style='text-align: center;' >
                {ifp 'member.member.edit'}
                <a href="{php echo webUrl('member/list/detail',array('id'=>$item['mid']))}"> {$item['nickname']}</a>
                {else}
                {$item['nickname']}
                {/if}

                <br/>
                {$item['addressdata']['realname']}<br/>{$item['addressdata']['mobile']}</td>
            <td rowspan="{php echo count($item['goods'])}" style='text-align:center;' class="paytype">

                <!--{if $item['statusvalue'] > 0}-->
                <!--<label class='label label-{$item['css']}'>{$item['paytype']}</label>-->
                <!--{else if $item['statusvalue'] == 0}-->
                <!--{if $item['paytypevalue']!=3}-->
                <!--<label class='label label-default'>未支付</label>-->
                <!--{else}-->
                <!--<label class='label label-primary'>货到付款</label>-->
                <!--{/if}-->
                <!--{else if $item['statusvalue'] == -1}-->
                <!--<label class='label label-default'>{$item['paytype']}</label>-->
                <!--{/if}-->
                {if $item['statusvalue'] > 0}
                {if $item['paytypevalue']==1}
                <span> <i class="icow icow-yue text-warning" style="font-size: 17px;"></i><span>余额支付</span></span>
                {elseif $item['paytypevalue']==11}
                <span> <i class="icow icow-kuajingzhifuiconfukuan text-danger" style="font-size: 17px"></i>后台付款</span>
                {elseif $item['paytypevalue']==21}
                <span> <i class="icow icow-weixinzhifu text-success" style="font-size: 17px"></i>微信支付</span>
                {elseif $item['paytypevalue']==22}
                <span><i class="icow icow-zhifubaozhifu text-primary" style="font-size: 17px"></i>支付宝支付</span>
                {/if}
                {else if $item['statusvalue'] == 0}
                <!-- 未支付 -->
                {if $item['paytypevalue']!=3}
                <span>
                     <i class="icow icow-shibai text-danger"></i>未支付
                </span>
                {else}
                <span> <i class="text-primary icow icow-icon" style="font-size: 17px"></i>货到付款</span>
                {/if}
                {else if $item['statusvalue'] == -1}
                {if $item['paytypevalue']==1}
                <span> <i class="icow icow-yue text-warning" style="font-size: 17px;"></i><span>余额支付</span></span>
                {elseif $item['paytypevalue']==11}
                <span> <i class="icow icow-kuajingzhifuiconfukuan text-danger" style="font-size: 17px"></i>后台付款</span>
                {elseif $item['paytypevalue']==21}
                <span> <i class="icow icow-weixin text-success" style="font-size: 17px"></i>微信支付</span>
                {elseif $item['paytypevalue']==22}
                <span><i class="icow icow-zhifubao text-primary" style="font-size: 17px"></i>支付宝支付</span>
                {/if}
                {/if}
                <br/>


                <span style='margin-top:5px;display:block;'>{$item['dispatchname']}</span>

            </td>
            <td  rowspan="{php echo count($item['goods'])}"  >
                <div style="width: 100%;height: 100%;cursor: pointer" data-toggle='popover' data-html='true' data-placement='right' data-trigger="hover"
                                                               data-content="<table style='width:100%;'>
                    <tr>
                        <td  style='border:none;text-align:right;'>商品小计：</td>
                        <td  style='border:none;text-align:right;;'>￥{php echo number_format( $item['goodsprice'] ,2)}</td>
                    </tr>
                    <tr>
                        <td  style='border:none;text-align:right;'>运费：</td>
                        <td  style='border:none;text-align:right;;'>￥{php echo number_format( $item['olddispatchprice'],2)}</td>
                    </tr>
                    {if $item['discountprice']>0}
                    <tr>
                        <td  style='border:none;text-align:right;'>会员折扣：</td>
                        <td  style='border:none;text-align:right;;'>-￥{php echo number_format( $item['discountprice'],2)}</td>
                    </tr>
                    {/if}
                    {if $item['deductprice']>0}
                    <tr>
                        <td  style='border:none;text-align:right;'>积分抵扣：</td>
                        <td  style='border:none;text-align:right;;'>-￥{php echo number_format( $item['deductprice'],2)}</td>
                    </tr>
                    {/if}
                    {if $item['deductcredit2']>0}
                    <tr>
                        <td  style='border:none;text-align:right;'>余额抵扣：</td>
                        <td  style='border:none;text-align:right;;'>-￥{php echo number_format( $item['deductcredit2'],2)}</td>
                    </tr>
                    {/if}
                    {if $item['deductenough']>0}
                    <tr>
                        <td  style='border:none;text-align:right;'>商城满额立减：</td>
                        <td  style='border:none;text-align:right;;'>-￥{php echo number_format( $item['deductenough'],2)}</td>
                    </tr>
                    {/if}
                    {if $item['merchdeductenough']>0}
                    <tr>
                        <td  style='border:none;text-align:right;'>商户满额立减：</td>
                        <td  style='border:none;text-align:right;;'>-￥{php echo number_format( $item['merchdeductenough'],2)}</td>
                    </tr>
                    {/if}
                    {if $item['couponprice']>0}
                    <tr>
                        <td  style='border:none;text-align:right;'>优惠券优惠：</td>
                        <td  style='border:none;text-align:right;;'>-￥{php echo number_format( $item['couponprice'],2)}</td>
                    </tr>
                    {/if}
                    {if $item['isdiscountprice']>0}
                    <tr>
                        <td  style='border:none;text-align:right;'>促销优惠：</td>
                        <td  style='border:none;text-align:right;;'>-￥{php echo number_format( $item['isdiscountprice'],2)}</td>
                    </tr>
                    {/if}

                    {if intval($item['changeprice'])!=0}
                    <tr>
                        <td  style='border:none;text-align:right;'>卖家改价：</td>
                        <td  style='border:none;text-align:right;;'><span style='{if 0<$item['changeprice']}color:green{else}color:red{/if}'>{if 0<$item['changeprice']}+{else}-{/if}￥{php echo number_format(abs($item['changeprice']),2)}</span></td>
                    </tr>
                    {/if}
                    {if intval($item['changedispatchprice'])!=0}
                    <tr>
                        <td  style='border:none;text-align:right;'>卖家改运费：</td>
                        <td  style='border:none;text-align:right;;'><span style='{if 0<$item['changedispatchprice']}color:green{else}color:red{/if}'>{if 0<$item['changedispatchprice']}+{else}-{/if}￥{php echo abs($item['changedispatchprice'])}</span></td>
                    </tr>
                    {/if}
                    <tr>
                        <td style='border:none;text-align:right;'>应收款：</td>
                        <td  style=`'border:none;text-align:right;color:green;'>￥{php echo number_format($item['price'],2)}</td>
                    </tr>

                </table>
    "
                    > ￥{php echo number_format($item['price'],2)} </div>
                {if $item['dispatchprice']>0}
                <br/>(含运费:￥{php echo number_format( $item['dispatchprice'],2)})
                {/if}


            </td>

            <td  rowspan="{php echo count($item['goods'])}" style='text-align:center' >
                <a class='op text-primary'  href="{php echo webUrl('order/detail', array('id' => $item['id']))}" >查看详情</a><br/>
                {if $item['addressid']!=0 && $item['statusvalue']>=2}
                <a class='op text-primary'  data-toggle="ajaxModal" href="{php echo webUrl('util/express', array('id' => $item['id'],'express'=>$item['express'],'expresssn'=>$item['expresssn']))}"   >物流信息</a>
                {/if}
            </td>

            <td  rowspan="{php echo count($item['goods'])}" style='text-align:center' >
                {ifp 'member.member.edit'}
                <a href="{php echo webUrl('member/list/detail',array('id'=>$item['m1']['id']))}"> {$item['m1']['nickname']}</a>
                {else}
                {$item['m1']['nickname']}
                {/if}

                <br/>
                {$item['m1']['realname']}<br/>{$item['m1']['mobile']}</td>
            </td>

            <td   rowspan="{php echo count($item['goods'])}" class='ops' style='line-height:20px;text-align:center' ><span class='text-{$item['statuscss']}'>{$item['status']}</span><br />
            </td>

            {/if}
        </tr>
        {/loop}












        {if !empty($item['remark'])}
        <tr ><td colspan='9' style='background:#fdeeee;color:red;'>买家备注: {$item['remark']}</td></tr>
        {/if}

        {if !empty($level) || (!empty($item['merchname']) && $item['merchid'] > 0)}
        <tr style=";border-bottom:none;background:#f9f9f9;">
            <td colspan='4' style='text-align:left'>
                {if !empty($item['merchname']) && $item['merchid'] > 0}
                商户名称:<span class="text-info">{$item['merchname']}</span>
                {/if}

            </td>
            <td colspan='5' style='text-align:right'>
                {if !empty($item['agentid'])}
                {if $item['commission1']!=-1}<b>1级佣金:</b> {$item['commission1']} 元 {/if}
                {if $item['commission2']!=-1}<b>2级佣金:</b> {$item['commission2']} 元 {/if}
                {if $item['commission3']!=-1}<b>3级佣金:</b> {$item['commission3']} 元 {/if}
                {/if}

                {if !empty($item['agentid']) && !$is_merch[$item['id']]}
                {ifp 'commission.apply.changecommission'}
                <!--a data-toggle="ajaxModal"  href="{php echo webUrl('commission/apply/changecommission', array('id' => $item['id']))}">修改佣金</a-->
                {/if}
                {/if}
            </td></tr>
        {/if}
        {/loop}
    </table>
    <div style="text-align:right;width:100%;">
        {$pager}
    </div>
    {else}

    <div class='panel panel-default'>
        <div class='panel-body' style='text-align: center;padding:30px;'>
            暂时没有任何订单!
        </div>
    </div>
    {/if}
</div>
{template '_footer'}
